home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-0195.lzh / AMOSLIST / text0264.txt < prev    next >
Encoding:
Text File  |  1995-02-01  |  3.4 KB  |  127 lines

  1. > I have a few questions about Amos Pro:
  2. > 1) Is there an AGA extension yet?
  3.  
  4. No, only andy churches intuition extension which works for AGA inuition
  5. screens. AGA is to central to AMOS to be fixed from an extension - it needs
  6. an AMOSPro re-write.
  7.  
  8. > 2) Is there any way to read a two-button joystick from either port?
  9.  
  10. Everyone always answers this with "Get hold of sticks extension", but no-one
  11. actually says how to get hold of sticks extension _ I haven't a clue.
  12.  
  13.  
  14. > And a general question about coding:
  15. > What is a good procedure for detecting a "tap" of a fire button and a 
  16. > "press" (button held down)? Right now I have something like
  17. > Procedure TESTHOLDBUTTON[STICK]
  18. > '
  19. > ' STICK is the port number
  20. > '
  21. > X = TRUE
  22. > DELAY = 1200 : ' this is arbitrary
  23. > While X = True
  24. >     X = Fire(STICK)
  25. >     Z = Z + 1
  26. >     If Z > DELAY Then X = False : ' Break out of loop if button held
  27. > too long                     
  28. > Wend
  29. > If Z < DELAY
  30. >     R = False
  31. > Else
  32. >     R = True
  33. > End If
  34. > End Proc[R]
  35. > '
  36. > ' R tells calling procedure whether button was tapped (False) or pressed 
  37. > ' (True).
  38. > '
  39. > This procedure works fine except that when I let go of the pressed button, 
  40. > the procedure registers a press AND a tap. I suspect that it's because 
  41. > a) procedure is called
  42. > b) procedure is exited when "True" is returned, but button is still held
  43. > c) procedure is called and exited again and again...
  44. > d) eventually, Z < DELAY after n number of procedure calls
  45. > Any way to fix this?
  46.  
  47. PROCEDURE TESTHOLDBUTTON[STICK]
  48.    Shared LAST_TIME,START_TIME
  49.  
  50.    If Fire(STICK) 
  51.       If LAST_TIME
  52.      'Button is still held from previous call
  53.         Pop Proc[-1]
  54.       Else
  55.      If START_TIME=0
  56.         'Beginning of a new press
  57.         START_TIME=Timer
  58.         Pop Proc[0]
  59.      Else
  60.         'Button pressed in a previous call, but
  61.         'timeout for a tap has not expired yet
  62.         If Timer-STARTTIME<2000
  63.            'Cant decide which it is yet
  64.            Pop Proc[0]
  65.         Else
  66.            'Decided it is a press
  67.         LAST_TIME=True
  68.         Pop Proc[-1]
  69.         End If
  70.      End If
  71.       End If
  72.    Else
  73.       'Button not pressed.
  74.       If LAST_TIME
  75.      'Just released from a press.
  76.      LAST_TIME=False
  77.      START_TIME=0
  78.      Pop Proc[0]
  79.       Else
  80.      If START_TIME
  81.         'Was a tap
  82.         START_TIME=0
  83.         Pop Proc[1]
  84.      Else
  85.         'Button Never Pressed at all.
  86.         Pop Proc[0]
  87.      End If
  88.       End If
  89.    End If
  90. End Proc
  91.     
  92. This returns:
  93.  
  94.     0 = Nothing as happend / the fire button is pressed, but not
  95.         enough time has passed to tell if it is a tap or press
  96.     1 = A tap has occured
  97.     -1 = A press has occured.
  98.  
  99. It also has that advantage that it doesn't wait in the procedure for
  100. 2000 50ths of a second, but exits immediately.As long as you call it
  101. regularly, there won't be a problem, but if you leave it too long
  102. between calls it might think taps are presses.
  103.  
  104. Note - I haven't tested this - I don't have an amiga handy.
  105.  
  106.  
  107. +-------------------------+------------------------------------+
  108. |                         |    _____                           |
  109. | PAUL HICKMAN            |   /     \   ON A HOT SUMMER NIGHT  |
  110. | (ph@doc.ic.ac.uk)       |  /  O O  \  WOULD YOU  OFFER YOUR  |
  111. | DEPARTMENT OF COMPUTING | |    _    | THROAT  TO  THE  WOLF  |
  112. | IMPERIAL COLLEGE LONDON |  \  / \  /  WITH THE RED  ROSES ?  |
  113. |                         |   \_____/                          |
  114. +-------------------------+------------------------------------+
  115. Machines: Amiga 500  WB1.3 - 1mb Memory - External Disk Drive.
  116.           Amiga 1200 WB3.0 - 6mb Memory - 200Mb Hard Disk.
  117.  
  118.  
  119.